/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * No deletion without permission, or be held responsible to law.
 * @author YDZ
 */
import { defHttp } from '/@/utils/http/axios';
import { useGlobSetting } from '/@/hooks/setting';
import { BasicModel, Page } from '../model/baseModel';
import { UploadApiResult } from './upload';
import { UploadFileParams } from '/#/axios';

const { ctxPath, adminPath } = useGlobSetting();

export interface BasMesOper extends BasicModel<BasMesOper> {
  code?: string; // 工序编码
  name?: string; // 工序名称
  workShopCode?: string; // 归属车间
  bkey?: string; // 关键工序
  costType?: string; // 计价方式
  techLevel?: string; // 技能标准
  techCtrl?: string; // 技能控制
  reportType?: string; // 报工方式
  bout?: string; // 是否委外
  breport?: string; // 是否报工
  bcheck?: string; // 是否检验
}

export const basMesOperList = (params?: BasMesOper | any) =>
  defHttp.get<BasMesOper>({ url: adminPath + '/bas/mes/oper/basMesOper/list', params });

export const basMesOperListData = (params?: BasMesOper | any) =>
  defHttp.post<Page<BasMesOper>>({ url: adminPath + '/bas/mes/oper/basMesOper/listData', params });

export const basMesOperForm = (params?: BasMesOper | any) =>
  defHttp.get<BasMesOper>({ url: adminPath + '/bas/mes/oper/basMesOper/form', params });

export const basMesOperSave = (params?: any, data?: BasMesOper | any) =>
  defHttp.postJson<BasMesOper>({ url: adminPath + '/bas/mes/oper/basMesOper/save', params, data });

export const basMesOperDisable = (params?: BasMesOper | any) =>
  defHttp.get<BasMesOper>({ url: adminPath + '/bas/mes/oper/basMesOper/disable', params });

export const basMesOperEnable = (params?: BasMesOper | any) =>
  defHttp.get<BasMesOper>({ url: adminPath + '/bas/mes/oper/basMesOper/enable', params });

export const basMesOperDelete = (params?: BasMesOper | any) =>
  defHttp.get<BasMesOper>({ url: adminPath + '/bas/mes/oper/basMesOper/delete', params });

export const basMesOperTreeData = (params?: BasMesOper | any) =>
  defHttp.post<Page<BasMesOper>>({ url: adminPath + '/bas/mes/oper/basMesOper/treeData', params });

export const basMesOperImportData = (
  params: UploadFileParams,
  onUploadProgress: (progressEvent: ProgressEvent) => void,
) =>
  defHttp.uploadFile<UploadApiResult>(
    {
      url: ctxPath + adminPath + '/bas/mes/oper/basMesOper/importData',
      onUploadProgress,
    },
    params,
  );
